#region "RunPlatformRegistration"

/*
 * ####     Developer Name : Wang Yucai
 * 
 * ####     Development Tool : Microsoft VisualStudio 2010 Ultimate Edition
 * 
 * ####     Create Time : 2014-07-09 15:10:15
 * 
 * ####     Namespace : Masterduner.SourceStudio.Practices.DevelopmentLibrary.Runtime
 * 
 * ####     Type Name : RunPlatformRegistration
 * 
 * ####     Full Name : Masterduner.SourceStudio.Practices.DevelopmentLibrary.Runtime.RunPlatformRegistration
 * 
 * ####     Machine Name : GLCHQWYCWINW7
 * 
 * ####     UserName : GUOCOLAND/wangyucai
 * 
 * ####     CLR Version : 4.0.30319.18444
 * 
 * ####     Target Framework Version : 4.0
 */

#endregion

using System;
using System.Web;

namespace Masterduner.SourceStudio.Practices.DevelopmentLibrary.Runtime
{
    /// <summary>
    /// <para>Masterduner.SourceStudio.Practices.DevelopmentLibrary.Runtime.RunPlatformRegistration</para>
    /// <para>
    /// 提供了注册应用运行平台的方法。
    /// </para>
    /// </summary>
    /// <remarks>
    /// <para>Target Framework Version : 4.0</para>
    /// </remarks>
    public class RunPlatformRegistration
    {
        static private RunPlatformID _platform = RunPlatformID.Unknown;

        #region Platform
        /// <summary>
        /// 获取运行平台类型。
        /// </summary>
        static public RunPlatformID Platform
        {
            get { return _platform; }
        }
        #endregion

        #region Constructor

        /// <summary>
        /// <para>构造函数：</para>
        /// <para>初始化一个<see cref="RunPlatformRegistration" />对象实例。</para>
        /// </summary>
        public RunPlatformRegistration()
        {
        }

        #endregion

        #region RegisterPlatformID
        /// <summary>
        /// 注册运行平台。
        /// </summary>
        /// <param name="platform"><see cref="RunPlatformID"/>中的一个值。</param>
        public static void RegisterPlatformID(RunPlatformID platform)
        {
            _platform = platform;
        }
        #endregion

        #region AutoDiscoverPlatform
        /// <summary>
        /// 自动发现运行平台值。
        /// </summary>
        /// <returns><see cref="RunPlatformID"/>中的一个值。</returns>
        static public RunPlatformID AutoDiscoverPlatform()
        {
            if (!HttpRuntime.AppDomainId.IsEmptyOrWriteSpaces() || !HttpRuntime.AppDomainAppId.IsEmptyOrWriteSpaces() || !AppDomain.CurrentDomain.FriendlyName.ToLower().EndsWith(".exe"))
            {
                return RunPlatformID.AspNet;
            }
            else
            {
                return RunPlatformID.WindowsForm;
            }
        }
        #endregion
    }
}

#region README

/*
 * ####     ©2014 Wang Yucai
 * 
 * ####     Contact me
 *                  
 *                  E-mail : Masterduner@Yeah.net
 *                  Mobile : 13621384677
 *                  QQ : 180261899
 */

#endregion